# Translated from SVG: http://www.w3.org/TR/SVG11/images/shapes/rect02.svg (the
# file is included)

require 'Vu/SVG/all'

puts "Constructing nodes..."

svg = Vu::SVG::SVG.new
svg.width = Vu::SVG::Abstract.new(12,:cm)
svg.height = Vu::SVG::Abstract.new(4,:cm)
svg.view_box = Vu::SVG::Bounds.new(0, 0, 1200, 400)

	# Outline
	o = Vu::SVG::Rect.new
	o.x = 1
	o.y = 1
	o.width = 1198
	o.height = 398
	o.fill = nil
	o.stroke = Vu::SVG::Colour.Blue
	o.stroke_width = 2
	
	svg.add_child(o)

	# Normal green rounded rect
	r1 = Vu::SVG::Rect.new
	r1.x = 100
	r1.y = 100
	r1.width = 400
	r1.height = 200
	r1.rx = 50
	r1.fill = Vu::SVG::Colour.Green
	
	svg.add_child(r1)

	# Group with transformation for purple rect
	g = Vu::SVG::Group.new
	g.transform.translate!(700,210)
	g.transform.rotate!(-3.141/6)		# TODO: support degrees!
		
		# Purple transformed rectangle
		r2 = Vu::SVG::Rect.new
		r2.x = 0
		r2.y = 0
		r2.width = 400
		r2.height = 200
		r2.rx = 50
		r2.fill = nil
		r2.stroke = Vu::SVG::Colour.Purple
		r2.stroke_width=30

		g.add_child(r2)
		
	svg.add_child(g)
	
puts "Dumping (foo.png)..."
svg.write_to_png("foo.png")
